<template>
  <div>
    <!-- MA交叉策略参数 -->
    <el-row :gutter="20" v-if="backtestSettings.strategyType === 'ma_cross'">
      <el-col :span="8">
        <el-form-item label="快速MA周期">
          <el-input-number v-model="backtestSettings.fastMAPeriod" :min="5" :step="1" :max="50"></el-input-number>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="慢速MA周期">
          <el-input-number v-model="backtestSettings.slowMAPeriod" :min="10" :step="1" :max="100"></el-input-number>
        </el-form-item>
      </el-col>
    </el-row>
    
    <!-- RSI策略参数 -->
    <el-row :gutter="20" v-if="backtestSettings.strategyType === 'rsi'">
      <el-col :span="8">
        <el-form-item label="RSI周期">
          <el-input-number v-model="backtestSettings.rsiPeriod" :min="5" :step="1" :max="30"></el-input-number>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="超买阈值">
          <el-input-number v-model="backtestSettings.overbought" :min="50" :step="1" :max="90"></el-input-number>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="超卖阈值">
          <el-input-number v-model="backtestSettings.oversold" :min="10" :step="1" :max="50"></el-input-number>
        </el-form-item>
      </el-col>
    </el-row>
    
    <!-- 布林带策略参数 -->
    <el-row :gutter="20" v-if="backtestSettings.strategyType === 'bollinger'">
      <el-col :span="8">
        <el-form-item label="布林带周期">
          <el-input-number v-model="backtestSettings.bbPeriod" :min="10" :step="1" :max="50"></el-input-number>
        </el-form-item>
      </el-col>
      <el-col :span="8">
        <el-form-item label="标准差倍数">
          <el-input-number v-model="backtestSettings.bbStdDev" :min="1" :step="0.1" :max="3"></el-input-number>
        </el-form-item>
      </el-col>
    </el-row>
    
    <!-- VWAP策略参数 -->
    <template v-if="backtestSettings.strategyType === 'vwap'">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-alert
            title="📈 VWAP策略说明"
            type="info"
            :closable="false"
            style="margin-bottom: 15px;"
          >
            <template #default>
              <div style="font-size: 13px; line-height: 1.5;">
                <p style="margin: 0 0 8px 0; font-weight: bold; color: #409eff;">策略原理：</p>
                <ul style="margin: 0; padding-left: 16px; color: #606266;">
                  <li>VWAP（成交量加权平均价格）反映了市场参与者的平均持仓成本</li>
                  <li>当价格上穿VWAP时，表明市场愿意以更高价格买入，显示买方力量增强</li>
                  <li>当价格下穿VWAP时，表明市场在较低价位卖出，显示卖方力量增强</li>
                  <li>适合趋势跟踪，在趋势市场中表现较好</li>
                  <li style="color: #e6a23c; font-weight: bold;">优化目标：提高盈利能力至20%，通过增加仓位和优化止盈策略</li>
                </ul>
                <p style="margin: 8px 0 0 0; font-weight: bold; color: #409eff;">数据源说明：</p>
                <ul style="margin: 0; padding-left: 16px; color: #606266;">
                  <li><strong>API数据：</strong>直接从交易所获取K线数据，数据更准确但更新频率较低</li>
                  <li><strong>网页实时数据：</strong>使用Binance图表中的价格数据，数据更实时但可能不够准确</li>
                  <li><strong>推荐设置：</strong>回测时建议使用API数据以获得更准确的结果，实时交易时可根据个人偏好选择</li>
                </ul>
              </div>
            </template>
          </el-alert>
        </el-col>
      </el-row>
      
      <!-- VWAP数据源选择 -->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="VWAP数据源">
            <el-select v-model="backtestSettings.vwapDataSource" placeholder="选择数据源">
              <el-option label="网页实时数据" value="web"></el-option>
              <el-option label="API数据" value="api"></el-option>
            </el-select>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">
              <span v-if="backtestSettings.vwapDataSource === 'api'">API数据更准确，直接从交易所获取K线数据</span>
              <span v-else>网页数据更实时，使用Binance图表中的价格数据</span>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="优化目标">
            <el-tag type="success">提高盈利能力至20%</el-tag>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">
              通过增加仓位(50%)和优化止盈策略(20%)
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </template>
    
    <!-- 自定义策略参数 -->
    <el-row :gutter="20" v-if="backtestSettings.strategyType === 'custom'">
      <el-col :span="24">
        <el-form-item label="自定义策略代码">
          <el-input 
            v-model="backtestSettings.customStrategy" 
            type="textarea" 
            :rows="4" 
            placeholder="输入您的自定义策略代码"
          ></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    
    <!-- AI智能策略1参数 -->
    <template v-if="backtestSettings.strategyType === 'ml_strategy1'">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-alert
            title="🤖 AI智能策略1 - 基于机器学习的多因子量化交易策略"
            type="info"
            :closable="false"
            style="margin-bottom: 15px;"
          >
            <template #default>
              <div style="font-size: 13px; line-height: 1.5;">
                <p style="margin: 0 0 8px 0; font-weight: bold; color: #409eff;">策略亮点：</p>
                <ul style="margin: 0; padding-left: 16px; color: #606266;">
                  <li>集成多种技术指标：MA、RSI、MACD、布林带、ATR、成交量等</li>
                  <li>使用机器学习算法对市场状态进行智能识别</li>
                  <li>动态止盈止损机制，根据市场波动性自动调整</li>
                  <li>市场情绪分析，识别恐慌与贪婪信号</li>
                  <li>多市场环境适应：牛市、熊市、震荡市</li>
                </ul>
              </div>
            </template>
          </el-alert>
        </el-col>
      </el-row>
      
      <!-- AI智能策略1详细参数配置 -->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="模型置信度阈值">
            <el-input-number v-model="backtestSettings.mlConfidenceThreshold" :min="0.6" :step="0.05" :max="0.95" :precision="2" style="width: 100%;"></el-input-number>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">推荐0.75，置信度越高交易越保守，建议0.7-0.85</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="特征权重调整">
            <el-select v-model="backtestSettings.mlFeatureWeighting" placeholder="选择特征权重" style="width: 100%;">
              <el-option label="均衡模式" value="balanced"></el-option>
              <el-option label="趋势优先" value="trend_focused"></el-option>
              <el-option label="动量优先" value="momentum_focused"></el-option>
              <el-option label="反转优先" value="reversal_focused"></el-option>
            </el-select>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">均衡模式适合大多数市场环境</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="市场状态感知">
            <el-switch
              v-model="backtestSettings.mlMarketStateAware"
              active-text="开启"
              inactive-text="关闭"
              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
            />
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">自动识别牛市、熊市、震荡市</div>
          </el-form-item>
        </el-col>
      </el-row>
      
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="动态仓位管理">
            <el-switch
              v-model="backtestSettings.mlDynamicPositioning"
              active-text="开启"
              inactive-text="关闭"
              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
            />
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">根据市场波动性和连续亏损动态调整仓位</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="情绪指标权重">
            <el-input-number v-model="backtestSettings.mlSentimentWeight" :min="0" :step="0.1" :max="1" :precision="1" style="width: 100%;"></el-input-number>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">市场情绪分析的权重，包含恐慌贪婪指数</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="智能止损系数">
            <el-input-number v-model="backtestSettings.mlAdaptiveStopLoss" :min="1" :step="0.1" :max="3" :precision="1" style="width: 100%;"></el-input-number>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">基于ATR的智能止损倍数</div>
          </el-form-item>
        </el-col>
      </el-row>
      
      <!-- 新增：AI策略高级参数 -->
      <el-row :gutter="20">
        <el-col :span="24">
          <el-divider content-position="left">
            <span style="color: #722ed1; font-weight: bold;">🔬 高级AI参数</span>
          </el-divider>
        </el-col>
      </el-row>
      
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="风险过滤器">
            <el-switch
              v-model="backtestSettings.mlRiskFilter"
              active-text="开启"
              inactive-text="关闭"
              style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
            />
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">智能风险控制，连续亏损和极端市场保护</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="信号强度阈值">
            <el-input-number v-model="backtestSettings.mlSignalThreshold" :min="0.5" :step="0.05" :max="0.8" :precision="2" style="width: 100%;"></el-input-number>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">信号触发的最低强度要求</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="多因子融合">
            <el-select v-model="backtestSettings.mlMultiFactorMode" placeholder="选择融合模式" style="width: 100%;">
              <el-option label="线性加权" value="linear"></el-option>
              <el-option label="非线性融合" value="nonlinear"></el-option>
              <el-option label="自适应权重" value="adaptive"></el-option>
            </el-select>
            <div style="font-size: 12px; color: #909399; margin-top: 2px;">多个技术指标的融合方式</div>
          </el-form-item>
        </el-col>
      </el-row>
    </template>
  </div>
</template>

<script>
export default {
  name: 'StrategyParameters',
  props: {
    backtestSettings: {
      type: Object,
      required: true
    }
  }
}
</script>

<style scoped>
/* 样式已在主组件中定义 */
</style>